<?php
session_start();
?>
<link href="style.css" rel="stylesheet" type="text/css" media="screen" />

<?php
include_once "functions.php";
include_once "header.php";
echo "<br /><br />";
include_once "headingbar.php"; 
if(isset($_POST['submit']))
{
    $errorMessage = "";
    $username = trim($_POST['username']);
    $password = trim($_POST['password']);

    if(empty($errorMessage))
    {
            //check username/password against record

            if(validateUser($username,$password))
            {
             $_SESSION['username'] = $username;
            
            include_once "myFavourites.php";
            exit;
            }else {
                $username = "";
                $password = "";
                $errorMessage .= "<b>Incorrect username or password.</b>";
            }
        }
    }
        ?>
            <br /><br /><br />
            <center>
            <h4>Welcome to digifilms, Please Login to to continue.</h4>
            <h4>If you don't have an account please register a user.</h4>
    <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
        <br />
        <p align="center">
        Username  : <input name="username" type="text" value="<?php echo $username; ?>"/>
        <br />
        Password   : <input name="password" type="text" value="<?php echo $password; ?>" />
        <br />
        <input type="submit" name="submit" value="LOGIN" />  
        <a href="register.php"><input type="reset" name="Register" value="Register" />  </a>
        </form>
        <br /><br /><br /><br />
<?php
 //Display the Error Message After The Form.
if(!empty($errorMessage))
        {
        echo("<p align='center'>" . $errorMessage . "</p>\n");
        } 

 include_once "footer.php"
?>   